<template>
<div class="collect-wrap">
    <G_header title="我的收藏" />
    <div>
        <van-card v-for="(item,index) in goods" :key="index" :price="item.good.price" desc="" :title="item.good.title" :thumb="item.good.avatar" @click="getGoods(item)">
			<div slot="footer">
				<van-button @click.stop="deleteGoodsl(item)" size="mini">删除</van-button>
			</div>
        </van-card>
    </div>

</div>
</template>

<script>
import { Toast } from 'vant';
export default {
    name: 'Collect',
    data() {
        return {
			goods: []
		}
	},
	created() {
		this.getData()
    },
    methods: {
		async getData() {
			let params = {
				token: sessionStorage.getItem('token')
			}
			const r = await this.axios.get('/api/store/user/favorite/list/Good',{params})
			this.goods = r.data.data.data;
		},
		getGoods(e){
			this.global.state.productStore_goods = e.good;
				this.$router.push({name:'productStore',path:'../product/store'})
		},
		async deleteGoodsl(item){
			let params = {
				token: sessionStorage.getItem('token')
			}
			const r = await this.axios.get('/api/store/user/favorite/delete/'+item.id,{params})
			if(r) Toast('删除成功');
			this.getData()
			
		}

    }
}
</script>

<style scoped>

</style>
